package hn.cch.spring.mvc.scope.bean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RequestMapping(value = "/bean")
@RestController
public class BeanController {

    @Lazy
    @Autowired
    private BeanApplication beanApplication;

    @Lazy
    @Autowired
    private BeanSession beanSession;

    @Lazy
    @Autowired
    private BeanRequest beanRequest;

    @RequestMapping(value = "/getBeans", method = RequestMethod.GET, produces = "text/plain")
    public String getBeans(HttpServletRequest request, HttpSession session) {
        ServletContext servletContext = request.getServletContext();
        return "beanApplication" + beanApplication +
                "\nbeanSession" + beanSession +
                "\nbeanRequest" + beanRequest;
    }

}
